package auth

import (
	"context"

	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/types"
	v1 "gitee.com/liuxuezhan/ar-platform/rpc-client/authRoleClient/api/role/v1"

	"github.com/zeromicro/go-zero/core/logx"
)

type UpdateRoleLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

// 更新角色信息
func NewUpdateRoleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateRoleLogic {
	return &UpdateRoleLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UpdateRoleLogic) UpdateRole(req *types.UpdateRoleRequest) error {
	_, err := l.svcCtx.AuthRoleRpc.UpdateRole(l.ctx, &v1.UpdateRoleRequest{
		Id:          req.Id,
		RolePid:     req.RolePid,
		RoleName:    req.RoleName,
		Description: req.Description,
		Remark:      req.Remark,
		ListOrder:   req.ListOrder,
		Status:      v1.Status(req.Status),
	})

	return err
}
